function jsxToJs(code) {
    // 递归处理嵌套标签
    function transformTag(tag) {
        let match = tag.match(/<(\w+)([^>]*)>(.*?)<\/\1>/);
        if (match) {
            let tagName = match[1];
            let props = match[2].replace(/className=/g, "class=");
            let children = match[3];
            return `React.createElement('${tagName}', ${props ? `{${props}}` : 'null'}, ${transformTag(children)})`;
        } else {
            return `'${tag.trim()}'`;
        }
    }

    // 替换所有的标签
    code = code.replace(/<(\w+)([^>]*)>(.*?)<\/\1>/g, (match, p1, p2, p3) => {
        return transformTag(match);
    });

    return code;
}

// 示例 JSX 代码
const jsxCode = `
  <div className="container">
    <h1>Hello, world!</h1>
    <p>This is a simple JSX example.</p>
  </div>
`;

// 转换 JSX 代码为 JavaScript 代码
const jsCode = jsxToJs(jsxCode);

console.log(jsCode);
